package com.biz.primus.ms.depot.dao.repository;


import com.biz.primus.model.depot.enums.BusinessStatus;
import com.biz.primus.ms.base.jpa.repository.CommonJpaRepository;
import com.biz.primus.ms.depot.dao.po.Depot;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Collection;
import java.util.List;

/**
 * @author lei
 * @date 2016/12/12
 * @reviewer
 * @see
 */
@Repository
public interface DepotRepository extends CommonJpaRepository<Depot, Long>, DepotDao {

    /**
     * 根据门店编码获取门店
     *
     * @param depotCode 门店编码
     * @return Depot
     */
    Depot findByDepotCode(String depotCode);

    /**
     * 根据门店编码获取门店
     *
     * @param depotCodes 门店编码集
     * @return List<Depot>
     */
    List<Depot> findByDepotCodeIn(Collection<String> depotCodes);

    /**
     * 根据门店编码获取门店
     *
     * @param status      门店营业状态
     * @param pageRequest 分页对象
     * @return Page<Depot>
     */
    @Query("select o from Depot o where o.bizStatus = ?1")
    Page<Depot> findByBizStatus(BusinessStatus status, Pageable pageRequest);
}
